To get the hats you need to summon them by using this command:

/give @s minecraft:carved_pumpkin{display:{Name:"{\"text\":\"HATNAMEHERE\"}"},CustomModelData:1}

To get the hat you want you need to change the number after "CustomModelData:" to one of the following:

1 - Wizard Hat
2 - Gift Hat
3 - Merchant Hat
4 - Crown
5 - Fancy Hat
6 - Very Fancy Hat
7 - Chef Hat
8 - Farmer Hat
9 - Top Hat
10 - Wig
11 - Green Wizard Hat
12 - Joker Hat
13 - Cluckshroom Hat
14 - Explorer Hat
15 - Detective Hat

I Hope You Enjoy!